package com.healthyeating.manage.controller;

import com.healthyeating.common.core.controller.BaseController;
import com.healthyeating.common.core.domain.AjaxResult;
import com.healthyeating.manage.domain.Chart;
import com.healthyeating.manage.domain.dto.ChartDto;
import com.healthyeating.manage.service.IChartService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 图表展示Controller
 *
 * @author 段奇乐
 * @date 2024-01-07
 */
@RestController
@RequestMapping("/manage/showdata")
public class ChartController extends BaseController {

    @Autowired
    private IChartService chartService;

    /**
     * 查询今日进食摄入营养成分
     */
    @PreAuthorize("@ss.hasPermi('manage:showdata:list')")
    @GetMapping("/eatList")
    public AjaxResult getEatList() {
        List<Chart> list = chartService.dealWithEatChart();
        return success(list);
    }

    /**
     * 查询今日饮水摄入营养成分
     */
    @PreAuthorize("@ss.hasPermi('manage:showdata:list')")
    @GetMapping("/drinkList")
    public AjaxResult getDrinkList() {
        List<Chart> list = chartService.dealWithDrinkChart();
        return success(list);
    }

    /**
     * 查询今日进食摄入营养成分在标准值的占比
     */
    @PreAuthorize("@ss.hasPermi('manage:showdata:list')")
    @GetMapping("/eatPercentList")
    public AjaxResult getEatPercentList() {
        List<ChartDto> list = chartService.dealWithEatPercentChart();
        return success(list);
    }

    /**
     * 查询近7日进食摄入营养成分
     */
    @PreAuthorize("@ss.hasPermi('manage:showdata:list')")
    @GetMapping("/eatListWithDay")
    public AjaxResult getEatListWithDay() {
        List<ChartDto> list = chartService.dealWithEatChartWithDay();
        return success(list);
    }
}
